package com.lxx.onlineview.controller;

import com.lxx.onlineview.entity.po.Class;
import com.lxx.onlineview.results.Result;
import com.lxx.onlineview.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/class")
public class ClassController {
    @Autowired
    ClassService classServer;

    @RequestMapping("/update")
    public Result<Class> update(Class cla){
        return classServer.update(cla);
    }

    @RequestMapping("/get")
    public Result<Class> get(String name,String grade,String dname){
        return classServer.getByName(name,grade,dname);
    }

    @RequestMapping("/getList")
    public Result<List<Class>> getList(){ return classServer.getList();
    }

    /*@RequestMapping("/delete")
    public Result<String> delete(String name){
        return classServer.delete(name);
    }*/

    @RequestMapping("add")
    public Result<Class> getByUserName(Class cla){
        return classServer.addClass(cla);
    }
}
